#!/bin/sh
# PROVIDE: sbbs
# REQUIRE: login

. /etc/rc.subr

name=sbbs
rcvar=`set_rcvar`

load_rc_config ${name}

# Setup defaults...
# Define these sbbs_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#       /etc/rc.conf.d/sbbs
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
sbbs_enable=${sbbs_enable-"NO"}
sbbs_flags=${sbbs_flags-"d"}
sbbs_pidfile=${sbbs_pidfile-"/var/run/sbbs.pid"}
sbbs_dir=${sbbs_dir-"/sbbs"}
sbbs_ctrldir=${sbbs_ctrldir-"${sbbs_dir}/ctrl"}
sbbs_execdir=${sbbs_execdir-"${sbbs_dir}/exec"}
sbbs_program=${sbbs_program-"${sbbs_execdir}/sbbs"}
sbbs_procname=${sbbs_procname-"${sbbs_execdir}/sbbs"}
sbbs_shell=${sbbs_shell-"/bin/sh"}

status_cmd=sbbs_node
start_precmd=sbbs_env

command=${sbbs_program}
pidfile=${sbbs_pidfile}

sbbs_node()
{
	${sbbs_execdir}/node list
	echo
        if [ -n "$rc_pid" ]; then
                echo "${name} is running as pid $rc_pid."
        else
                echo "${name} is not running."
                return 1
        fi

}

sbbs_env()
{
	SHELL=$sbbs_shell
	export SHELL
	SBBSCTRL=$sbbs_ctrldir
	export SBBSCTRL
	PATH=/bin:/usr/bin:/usr/games:/usr/local/bin
	export PATH
}

extra_commands="config monitor uedit"
config_cmd=${sbbs_execdir}/scfg
monitor_cmd=${sbbs_execdir}/umonitor
uedit_cmd=${sbbs_execdir}/uedit

run_rc_command "$1"
